import collections
class Solution(object):
    def buddyStrings(self, s, goal):
        """
        :type s: str
        :type goal: str
        :rtype: bool
        """
        n1 = len(s)
        n2 = len(goal)
        if n1 != n2:
            return False
        if n1 == 1:
            return False
        st = []
        for i in range(n1):
            if s[i] != goal[i]:
                st.append(i)
        if not st:
            c = collections.Counter(s)
            for key in c:
                if c[key] >= 2:
                    return True
            return False
        if len(st) == 2:
            if s[st[0]] == goal[st[1]] and s[st[1]] == goal[st[0]]:
                return True
            else:
                return False
        else:
            return False


data = Solution()
s = "ab"
goal = "ab"
print(data.buddyStrings(s, goal))